<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>数据库管理</title>
<link href="css/default.css" rel="stylesheet" type="text/css" />
<script src="js/page.js"></script>
</head>

<body onload="initialize();">
<jsp:useBean id="database" class="DatabaseConnection.DatabaseConnection" />
<%@include file="connect_database.jsp" %>
<%
request.setCharacterEncoding("utf-8");
String deleted_data = request.getParameter("deleted_data");
String message = "";
String [] deleted_databases = deleted_data.split(",");
String successful_databases = "";
String failed_databases = "";
String sql_delete = "";
boolean success = false;
for (int i = 0; i < deleted_databases.length; i++)
{
	sql_delete = "drop database " + deleted_databases[i] + ";";
	success = database.executeUpdate(sql_delete);
	if (success == true)
		successful_databases = successful_databases + deleted_databases[i] + ", ";
	else
		failed_databases = failed_databases + deleted_databases[i] + ", ";
}
database.closeConnection();
if (successful_databases.length() > 0)
{
	successful_databases = successful_databases.substring(0, successful_databases.length() - 2);
	message = message + "数据库 " + successful_databases + " 删除成功";
}
if (failed_databases.length() > 0)
{
	failed_databases = failed_databases.substring(0, failed_databases.length() - 2);
	if (message.length() > 0)
		message = message + "，";
	message = message + "数据库 " + failed_databases + " 删除失败";
}
message = message + "！";
%>
<script type="text/javascript">
<!--
	window.alert("<%= message %>");
	window.location.href = "databases.jsp";
//-->
</script>
</body>
</html>